<%--
   jqGrid
   Copyright (c) 2013 ISPERP
   Version : 1.0.0
 --%>
<%@ tag language="java" pageEncoding="UTF-8"
	trimDirectiveWhitespaces="true"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ attribute name="title" required="true" type="java.lang.String"
	description="头部标题(th)."%>
<%@ attribute name="name" required="true" type="java.lang.String"
	description="为Grid中的每个列设置唯一的名称，这是一个必需选项。"%>
<%@ attribute name="index" required="false" type="java.lang.String"
	description="设置排序时所使用的索引名称，这个index名称会作为sidx参数（prmNames中设置的）传递到Server。"%>
<%@ attribute name="label" required="false" type="java.lang.String"
	description="当jqGrid的colNames选项数组为空时，为各列指定题头。如果colNames和此项都为空时，则name选项值会成为题头。"%>
<%@ attribute name="width" required="false" type="java.lang.String"
	description="设置列的宽度"%>
<%@ attribute name="align" required="false" type="java.lang.String"
	description="对其方式(默认为左侧对齐)."%>
<%@ attribute name="sortable" required="false" type="java.lang.Boolean"
	description="是设置该列是否可以排序，默认为true。"%>
<%@ attribute name="search" required="false" type="java.lang.Boolean"
	description="设置该列是否可以被列为搜索条件，默认为true。"%>
<%@ attribute name="fixed" required="false" type="java.lang.Boolean"
	description="列宽度是否要固定不可变"%>
<%@ attribute name="resizable" required="false" type="java.lang.Boolean"
	description="设置列是否可以变更尺寸，默认为true。"%>
<%@ attribute name="hidden" required="false" type="java.lang.Boolean"
	description="设置此列初始化时是否为隐藏状态，默认为false。"%>
<%@ attribute name="formatter" required="false" type="java.lang.String"
	description="预设类型或用来格式化该列的自定义函数名。常用预设格式有：integer、date、currency、number等。如果使用函数需要isFormatterFun为true，使用函数格式可用的参数有：(cellvalue, options, rowObject)"%>
<%@ attribute name="isFormatterFun" required="false"
	type="java.lang.Boolean"
	description="格式化是否采用函数。使用函数格式可用的参数有：(cellvalue, options, rowObject)。默认false"%>

<%@ attribute name="editable" required="false" type="java.lang.Boolean"
	description="是否可以编辑，默认false"%>
<%@ attribute name="edittype" required="false" type="java.lang.String"
	description="编辑的类型，可为text、textarea，select、checkbox、password、button、image、file等。默认空，并且只有在editable为true是才有效"%>


<%@ attribute name="showInHead" required="false"
	type="java.lang.Boolean" description="默认false，对于hidden不会显示"%>


<%@ attribute name="summaryType" required="false"
	type="java.lang.String" description=""%>
<%@ attribute name="summaryTpl" required="false" type="java.lang.String"
	description=""%>
<c:set var="formatoptions" scope="request" />

<c:choose>
	<c:when test="${empty columns}">
		<c:set var="columns" value="${name}" scope="request" />
	</c:when>
	<c:otherwise>
		<c:set var="columns" value="${columns},${name}" scope="request" />
	</c:otherwise>
</c:choose>

<c:if test="${empty formatoptions}">
	<c:set var="formatoptions" value="{}" scope="request" />
</c:if>
<jsp:doBody />
<c:choose>
	<c:when test="${empty colNames}">
		<c:set var="colNames" value="'${title}'" scope="request" />
	</c:when>
	<c:otherwise>
		<c:set var="colNames" value="${colNames},'${title}'" scope="request" />
	</c:otherwise>
</c:choose>
<c:choose>
	<c:when test="${empty colModel}">
		<c:set var="colModel" value="{label:'${title}',name:'${name}'"
			scope="request" />
	</c:when>
	<c:otherwise>
		<c:set var="colModel"
			value="${colModel},{label:'${title}',name:'${name}'" scope="request" />
	</c:otherwise>
</c:choose>

<c:set var="showInHead" value="${showInHead eq false?false:true}"
	scope="request" />

<c:set var="colModel" value="${colModel},showInHead:${showInHead }"
	scope="request" />

<c:if test="${not empty index}">
	<c:set var="colModel" value="${colModel},index:'${index}'"
		scope="request" />
</c:if>
<c:if test="${not empty label}">
	<c:set var="colModel" value="${colModel},label:'${label}'"
		scope="request" />
</c:if>
<c:if test="${not empty width}">
	<c:set var="colModel" value="${colModel},width:'${width}'"
		scope="request" />
</c:if>
<c:if test="${not empty align}">
	<c:set var="colModel" value="${colModel},align:'${align}'"
		scope="request" />
</c:if>
<c:if test="${not empty sortable}">
	<c:set var="colModel" value="${colModel},sortable:${sortable}"
		scope="request" />
</c:if>
<c:if test="${not empty search}">
	<c:set var="colModel" value="${colModel},search:${search}"
		scope="request" />
</c:if>
<c:if test="${not empty hidden}">
	<c:set var="colModel" value="${colModel},hidden:${hidden}"
		scope="request" />
</c:if>

<c:if test="${fixed eq true}">
	<c:set var="colModel" value="${colModel},fixed:true" scope="request" />
</c:if>

<c:if test="${editable eq true}">
	<c:set var="colModel"
		value="${colModel},editable:${editable},edittype:'${edittype }'"
		scope="request" />
</c:if>
<c:if test="${not empty summaryType}">
	<c:set var="colModel" value="${colModel},summaryType:'${summaryType}'"
		scope="request" />
</c:if>

<c:if test="${not empty summaryTpl}">
	<c:set var="colModel" value="${colModel},summaryTpl:'${summaryTpl}'"
		scope="request" />
</c:if>


<c:if test="${not empty formatter}">
	<c:choose>
		<c:when test="${not empty formatterValue or isFormatterFun eq true}">
			<c:set var="colModel"
				value="${colModel},formatter:function(cellvalue, options, rowObject){${formatter}}"
				scope="request" />
		</c:when>
		<c:otherwise>
			<c:set var="colModel"
				value="${colModel},formatter:'${formatter}',formatoptions:${formatoptions}"
				scope="request" />
		</c:otherwise>
	</c:choose>
</c:if>
<c:set var="colModel" value="${colModel}}" scope="request" />
